package com.dbMethod;

import com.lUtils.jdbcUtils;

import java.sql.*;
import java.time.LocalDateTime;

public class sql_InsertUser {
    public static int InsertUser(String CardId, int password, LocalDateTime transDate) {
        Connection con = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        int i=0;
        try{
            con=jdbcUtils.getConnection();
            ps=con.prepareStatement("INSERT INTO `cardinfo` (`cardID`, `password`,`openDate`) values(?,?,?) ");
            ps.setString(1, CardId);
            ps.setInt(2, password);
            ps.setTimestamp(3, Timestamp.valueOf(transDate));
            i = ps.executeUpdate();
           return i;

        }catch (SQLException e){
            e.printStackTrace();
        }
        finally {
            jdbcUtils.closeTheStream(rs, ps, con);
            return i;
        }

    }
}
